package cn.wolfcode.luowowo.article.controller;

import cn.wolfcode.luowowo.article.domain.StrategyTheme;
import cn.wolfcode.luowowo.article.service.IStrategyThemeService;
import cn.wolfcode.luowowo.common.query.StrategyThemeQueryObject;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/strategyTheme")
public class StrategyThemeController {
    @Reference
    private IStrategyThemeService strategyThemeService;
    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") StrategyThemeQueryObject qo){
        //pageInfo
        PageInfo pageInfo = strategyThemeService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "strategyTheme/list";
    }
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        //根据id删除记录
        strategyThemeService.deleteById(id);
        return new AjaxResult();
    }
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyTheme strategyTheme){
        //保存或者更新
        strategyThemeService.saveOrUpdate(strategyTheme);
        return new AjaxResult();
    }

}
